package com.qzl.feiq.config;

import com.qzl.feiq.enu.UserActionTypeEnum;
import com.qzl.feiq.message.Message;
import io.netty.channel.Channel;
import io.netty.channel.nio.NioEventLoopGroup;

import java.util.*;
import java.util.concurrent.BlockingQueue;
import java.util.concurrent.ConcurrentHashMap;
import java.util.concurrent.LinkedBlockingQueue;

public class FeiQCache {
    // 缓存所有在线的channel, 兼容多网卡
    public static Set<String> allIps = new HashSet<>();
    public static Map<String, Channel> udpChannelMap = new ConcurrentHashMap<>();
    public static Map<String, Channel> tcpChannelMap = new ConcurrentHashMap<>();
    public static Map<String, NioEventLoopGroup> udpEventLoopGroupMap = new ConcurrentHashMap<>();
    public static Map<String, List<NioEventLoopGroup>> tcpEventLoopGroupMap = new ConcurrentHashMap<>();
    // 缓存所有在线的用户 ip:username
    public static Map<String, String> onlineUsers = new ConcurrentHashMap<>();

    // 队列用于接收消息后在页面展示（线程间通信）
    public static final BlockingQueue<Message> messageQueue = new LinkedBlockingQueue<>();
    // 好友动态刷新
    public static final BlockingQueue<UserActionTypeEnum> userQueue = new LinkedBlockingQueue<>();
}
